//
//  NewsModel.m
//  coba-iOS
//
//  Created by 郭四虎 on 15/12/9.
//  Copyright © 2015年 YouKu. All rights reserved.
//

#import "NewsModel.h"

@implementation NewsModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"id"]) {
        self.newsid = value;
    }else if ([key isEqualToString:@"description"])
    {
        self.desc = value;
    }
}
- (instancetype)init
{
    if (self = [super init]) {
        
        self.num = [NSString stringWithFormat:@"%u",arc4random()%1000+100];
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.newsid forKey:@"newsid"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.promote_flag forKey:@"promote_flag"];
    [aCoder encodeObject:self.date forKey:@"date"];
    [aCoder encodeObject:self.desc forKey:@"desc"];
    [aCoder encodeObject:self.img_url forKey:@"img_url"];
    [aCoder encodeObject:self.summary forKey:@"summary"];
    [aCoder encodeObject:self.dir_name forKey:@"dir_name"];
    [aCoder encodeBool:self.is_read forKey:@"is_read"];
    [aCoder encodeObject:self.num forKey:@"num"];
    [aCoder encodeObject:self.author forKey:@"author"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
        
        self.newsid = [aDecoder decodeObjectForKey:@"newsid"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.promote_flag = [aDecoder decodeObjectForKey:@"promote_flag"];
        self.date = [aDecoder decodeObjectForKey:@"date"];
        self.desc = [aDecoder decodeObjectForKey:@"desc"];
        self.img_url = [aDecoder decodeObjectForKey:@"img_url"];
        self.summary = [aDecoder decodeObjectForKey:@"summary"];
        self.dir_name = [aDecoder decodeObjectForKey:@"dir_name"];
        self.is_read = [aDecoder decodeBoolForKey:@"is_read"];
        self.num = [aDecoder decodeObjectForKey:@"num"];
        self.author = [aDecoder decodeObjectForKey:@"author"];
    }
    
    return self;
}

@end
